<?php
namespace app\common\model;

use think\Model;
use think\Db;

class Project extends Model
{
    // 指定表名,不含前缀
    protected $name = 'project';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    public function getListByArgOne(array $arg,$field='*')
    {
        return $this->where($arg)->field($field)->find();
    }
	
    public function getList($admin_reg,$projectid=0){
        $where = 1;
        $child_plaform = [$admin_reg];
        $condition = '';
        if ($projectid!=0)$condition = " AND id=".$projectid;
		if ($this->plaform){
			$child_plaform = getChildAdminRegByPlaformId($this->plaform);array_push($child_plaform,$admin_reg);
		}

		
		/*************/
		$parent_id = Db::name('plaform')->where(['admin_reg'=>$_SESSION["think"]["reg"]])->field('parentid')->find();
		if($parent_id['parentid']){

			$adreg = Db::name('plaform')->where(['id'=>$parent_id['parentid'],'status'=>1])->field('admin_reg')->find();
			if(!empty($adreg['admin_reg'])){
				$child_plaform[] = $adreg['admin_reg'];
				
			}

			
		} 
	
		
		$where = ['admin_reg'=>['in',$child_plaform]];

		$arr=$this->field('id,name,pid')->where($where)->where('status=1 and isdelete=0  '.$condition)->select();
		
        return $arr;
    }
	

}
